package com.prs.crm.domain.purchase;

import java.sql.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;

import com.prs.crm.domain.BaseEntity;
import com.prs.crm.domain.store.StoreRoom;

/**
 * 退货出库
 * 
 * @author 兰小刚
 * @version 创建时间：2010-7-22 上午09:33:28 类说明
 */
@Entity
@Table(name = "purchase_PurchaseReturnedStoreOut")
public class PurchaseReturnedStoreOut extends BaseEntity {
	private static final long serialVersionUID = -4867503240956693033L;
	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Integer id;

	/**
	 * 退货出库主题
	 */
	private String outName;

	/**
	 * 仓库
	 */
	@ManyToOne
	private StoreRoom storeRoom;

	/**
	 * 出库日期
	 */
	private Date outDate;

	/**
	 * 明细
	 */
	@OneToMany(mappedBy = "purchaseReturnedStoreOut")
	@OrderBy
	@Cascade( { org.hibernate.annotations.CascadeType.ALL,
			org.hibernate.annotations.CascadeType.DELETE_ORPHAN })
	private Set<PurchaseReturnedStoreOutDetail> details;

	/**
	 * 概要
	 */
	@Lob
	private String remark;

	/**
	 * 状态
	 * 
	 * @return
	 */
	@Column(columnDefinition = "Integer(11) default '0'")
	private Integer inState;

	
	private String returnCode;
	/**
	 * 产品批号
	 */
	private String batchNum;

	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getOutName() {
		return outName;
	}

	public void setOutName(String outName) {
		this.outName = outName;
	}

	public StoreRoom getStoreRoom() {
		return storeRoom;
	}

	public void setStoreRoom(StoreRoom storeRoom) {
		this.storeRoom = storeRoom;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public Set<PurchaseReturnedStoreOutDetail> getDetails() {
		return details;
	}

	public void setDetails(Set<PurchaseReturnedStoreOutDetail> details) {
		this.details = details;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public void addDetail(PurchaseReturnedStoreOutDetail detail) {
		if (details == null)
			details = new HashSet<PurchaseReturnedStoreOutDetail>();
		detail.setPurchaseReturnedStoreOut(this);
		details.add(detail);
	}

	public Integer getInState() {
		return inState;
	}

	public void setInState(Integer inState) {
		this.inState = inState;
	}

	public String getReturnCode() {
		return returnCode;
	}

	public void setReturnCode(String returnCode) {
		this.returnCode = returnCode;
	}

	public String getBatchNum() {
		return batchNum;
	}

	public void setBatchNum(String batchNum) {
		this.batchNum = batchNum;
	}

}
